<?php

class StaticExample {
	static public $aNum = 0;

	/**
	 * Static Method
	 *
	 */
	static public function sayHello() {
		self::$aNum++; // self has the same mean as the this in the obj scope
		print "hello (".self::$aNum.")\n";
	}
}

class NormalClass {
	static public $aField = 10;
}


function func1() {
	$obj1 = new StaticExample();
	$obj1::$aNum = 20;
	$obj2 = new NormalClass();
	$obj2::$aField = 10;

	// static methods can be accessed from object instances
	// but they have all the same value
	print $obj1::$aNum;
	echo "<br>";
	print $obj2::$aField;
	echo "<br>";




	// no obj needed
	StaticExample::sayHello();
	StaticExample::sayHello();
	StaticExample::sayHello();
}



// func1();




abstract class DomainObject {
	public static function create() {
		// 		return new self();
		return new static();
	}
}

class User extends DomainObject {

}

class Document extends DomainObject {

}


function func02() {
	print_r(Document::create());
}


func02();

?>
